package jjn.carl.greedy;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author Jjn
 * @since 2023/7/29 18:24
 */
public class LeetCode455 {
    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int count = 0;
        for (int i = 0, j = 0; i < g.length && j < s.length; ) {
            if (s[j] >= g[i]) {
                count++;
                i++;
            }
            j++;
        }
        return count;
    }
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int gCount = scanner.nextInt();
        int sCount = scanner.nextInt();
        int[] g = new int[gCount];
        int[] s = new int[sCount];
        for (int i = 0; i < gCount; i++) {
            g[i] = scanner.nextInt();
        }
        for (int i = 0; i < sCount; i++) {
            s[i] = scanner.nextInt();
        }
        int contentChildren = new LeetCode455().findContentChildren(g, s);
        System.out.println(contentChildren);
    }
}
